import React from 'react'
import { Modal } from 'antd'
import LoginRight from '../../public/components/LoginRight'
import { showLoginModule } from '../action/action'
import { Map } from 'immutable'
import { connect } from 'react-redux'

class LoginModule extends React.PureComponent {
  constructor (props) {
    super(props)
    this.state = {
      vision: false
    }
  }

  setShowModal = () => {
    this.setState({
      vision: true
    })
  }

  componentDidMount () {
    const { dispatch } = this.props
    dispatch(showLoginModule(Map({ showLogin: this.setShowModal })))
  }

  onCancel = () => {
    this.setState({
      vision: false
    })
  }

  render () {
    const { vision } = this.state
    return (
      <Modal
        width="410px"
        open={vision}
        maskClosable={false}
        onCancel={this.onCancel}
        footer={null}
      >
        <LoginRight/>
      </Modal>
    )
  }
}

const mapStateToProps = (state) => {
  return {}
}
export default connect(mapStateToProps)(LoginModule)
